package com.itdaan.portal.business.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.itdaan.portal.business.domain.Group;
import com.itdaan.portal.business.mapper.GroupMapper;
import com.itdaan.portal.business.service.GroupService;
import com.itdaan.portal.common.exception.ServiceException;
/**
 * @author www.itdaan.com
 */
@Service(value = "groupService")
public class GroupServiceImpl implements GroupService {

	@Resource(name ="groupMapper")
	private GroupMapper groupMapper;
	
	@Override
	public List<Group> findGroupsPage(Group group) throws ServiceException {
		return groupMapper.selectGroupsPage(group);
	}

	@Override
	public Integer findGroupsCount(Group group) throws ServiceException {
		return groupMapper.selectGroupCount(group);
	}

	@Override
	public Group findGroupOne(Integer id) throws ServiceException {
		return groupMapper.selectByPrimaryKey(id);
	}

	@Override
	public int delGroup(String ids) throws ServiceException {
		String idss [] = ids.split(",");
		for(String id : idss){
			groupMapper.deleteByPrimaryKey(Integer.parseInt(id));
		}
		return 1;
	}

	@Override
	public int updateGroup(Group group) throws ServiceException {
		return groupMapper.updateByPrimaryKeySelective(group);
	}

	@Override
	public int addGroup(Group group) throws ServiceException {
		return groupMapper.insertSelective(group);
	}
	
	
	
}
